package com.example.hewei.smarttransport.Request;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * 用户登录请求类
 * Created by 何伟 on 2017/3/7.
 */

public class LoginRequest extends TrafficRequest {
    // action name
    private static final String ACTION = "login";

    private String userName;
    private String password;

    public LoginRequest(String userName) {
        super(userName);
    }

    @Override
    protected String getActionName() {
        return ACTION;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    /**
     * (non-Javadoc)
     */
    @Override
    protected String onGetJasonBody() {
        JSONObject jsonObj = new JSONObject();
        try {
            // 用户名
            jsonObj.put("username", userName);
            // 密码
            jsonObj.put("password", password);
            return jsonObj.toString();
        } catch (JSONException e) {
            e.printStackTrace();
        }
        return super.onGetJasonBody();
    }

}
